var xmlHttp; //定义XMLHttpRequest对象
function createXmlHttpRequestObject() {
    //如果在internet Explorer下运行
    if (window.ActiveXObject) {
        try {
            xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (e) {
            xmlHttp = false;
        }

    } else {
        //如果在Mozilla或其他的浏览器下运行
        try {
            xmlHttp = new XMLHttpRequest();
        } catch (e) {
            xmlHttp = false;
        }
    }
    //返回创建的对象或显示错误信息
    if (!xmlHttp)
        alert("返回创建的对象或显示错误信息");
    else
        return xmlHttp;
}

function sendDate(){
    createXmlHttpRequestObject();
    var b_date = document.getElementById("b-date").value;
    var e_date = document.getElementById("e-date").value;
    if (b_date != "" || e_date != "") {
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                document.getElementById("info-div-content").innerHTML = xmlHttp.responseText;
            }
        } //判断URL调用的状态值并处理
        xmlHttp.open("GET", 'd_AdmissionHistory.php?bDate=' + b_date + '&eDate=' + e_date , false);
        xmlHttp.send(null);
    }else{
        alert("起止日期至少选择一项才可筛选信息！");
    }
}

function refreshPage() {
    window.location.reload();
}

function sendCasesID(){
    createXmlHttpRequestObject();
    var casesID = document.getElementById("casesID").value;
    if (casesID != "") {
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                document.getElementById("info-div-content").innerHTML = xmlHttp.responseText;
            }
        } //判断URL调用的状态值并处理
        xmlHttp.open("GET", 'd_AdmissionHistory.php?sendcasesID=' + casesID , false);
        xmlHttp.send(null);
    }else{
        alert("请填写诊单ID再进行查询！");
    }
}

function sendUserID(){
    createXmlHttpRequestObject();
    var userID = document.getElementById("userID").value;
    if (userID != "") {
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                document.getElementById("info-div-content").innerHTML = xmlHttp.responseText;
            }
        } //判断URL调用的状态值并处理
        xmlHttp.open("GET", 'd_AdmissionHistory.php?senduserID=' + userID , false);
        xmlHttp.send(null);
    }else{
        alert("请填写用户ID再进行查询！");
    }
}

function sendPetID(){
    createXmlHttpRequestObject();
    var petID = document.getElementById("petID").value;
    if (petID != "") {
        xmlHttp.onreadystatechange = function () {
            if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
                document.getElementById("info-div-content").innerHTML = xmlHttp.responseText;
            }
        } //判断URL调用的状态值并处理
        xmlHttp.open("GET", 'd_AdmissionHistory.php?sendpetID=' + petID , false);
        xmlHttp.send(null);
    }else{
        alert("请填写宠物ID再进行查询！");
    }
}
